package com.meida.paotui.app.handler;


import com.meida.app.provider.handler.UserInfoHandler;
import com.meida.common.mybatis.model.ResultBody;
import com.meida.common.mybatis.query.CriteriaSave;
import com.meida.module.user.client.dto.LoginParams;
import com.meida.module.user.client.entity.AppUser;
import com.meida.module.user.provider.service.AppUserService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * APP接口扩展
 *
 * @author Administrator
 */
@Component
@Log4j2
public class UserInfoGetHandler implements UserInfoHandler {

    @Autowired
    private AppUserService userService;

    @Override
    public AppUser bindMobile(AppUser baseUser) {
        log.info("绑定手机号扩展,accountId:" + baseUser.getUserId());

        return baseUser;
    }

    @Override
    public void userReg(CriteriaSave cs) {

    }

    /**
     * 登录成功处理
     *
     * @param map
     * @param loginParams
     * @return
     */

    public ResultBody afterLogin(Map<String, Object> map, LoginParams loginParams) {
        AppUser appUser = userService.getUserByMobile(loginParams.getUsername());
        map.put("User", appUser);
        return ResultBody.ok();
    }


}
